//
//  RHFbContactCell.m
//  RuiHeAppApp
//
//  Created by Yan Chen on 2023/11/28.
//

#import "RHFbContactCell.h"

@implementation RHFbContactCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        [self setupUI];
    }
    return self;
}
-(void)setupUI{
    kWeakSelf;
    self.contentView.backgroundColor = CFTabViewBgColor;
    
    UIView *containView = kView;
    containView.backgroundColor = [UIColor whiteColor];
    [containView setMiddleBorder];
    [self.contentView addSubview:containView];
    [containView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15);
        make.right.mas_offset(-15);
        make.top.bottom.mas_offset(0);
    }];
    
   
    QMUILabel *tipLab = [[QMUILabel alloc]init];
    tipLab.text = @"*";
    tipLab.font = [UIFont systemFontOfSize:15];
    tipLab.textColor = [UIColor colorWithHexString:@"FB1D0E" alpha:1];
    [containView addSubview:tipLab];
    [tipLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15);
        make.top.mas_offset(10);
    }];
    
    QMUILabel *emailLab = [[QMUILabel alloc]init];
    emailLab.text = @"您的邮箱".rh_localized;
    emailLab.font = [UIFont systemFontOfSize:15];
    emailLab.textColor = [UIColor colorWithHexString:@"3F4443" alpha:0.8];
    [containView addSubview:emailLab];
    [emailLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(tipLab.mas_right);
        make.top.mas_offset(10);
    }];
    
    QMUITextField *emailTFD = [[QMUITextField alloc]init];
    emailTFD.placeholder = @"您的邮箱".rh_localized;
    emailTFD.keyboardType = UIKeyboardTypeEmailAddress;
    emailTFD.layer.cornerRadius = 8;
    emailTFD.layer.masksToBounds = YES;
    emailTFD.backgroundColor = kCOLOR_HEX(@"#F4F6F9");
    emailTFD.font = [UIFont systemFontOfSize:15];
    UIView *leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, 10)];
    emailTFD.leftView = leftView;
    emailTFD.leftViewMode = UITextFieldViewModeAlways;
    emailTFD.placeholderColor = [UIColor colorWithHexString:@"3F4443" alpha:0.4];
    [containView addSubview:emailTFD];
    
    [emailTFD mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15);
        make.right.mas_offset(-15);
        make.height.offset(50);
        make.top.equalTo(emailLab.mas_bottom).offset(10);
    }];
    
    
    QMUILabel *phoneLab = [[QMUILabel alloc]init];
    phoneLab.text = @"您的电话".rh_localized;
    phoneLab.font = [UIFont systemFontOfSize:15];
    phoneLab.textColor = [UIColor colorWithHexString:@"3F4443" alpha:0.8];
    [containView addSubview:phoneLab];
    [phoneLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15);
        make.top.equalTo(emailTFD.mas_bottom).offset(15);
    }];
    
    QMUITextField *phoneTFD = [[QMUITextField alloc]init];
    phoneTFD.placeholder = @"您的电话".rh_localized;
    phoneTFD.layer.cornerRadius = 8;
    phoneTFD.layer.masksToBounds = YES;
    phoneTFD.backgroundColor = kCOLOR_HEX(@"#F4F6F9");
    phoneTFD.font = [UIFont systemFontOfSize:15];
    UIView *leftView1= [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, 10)];
    phoneTFD.leftView = leftView1;
    phoneTFD.leftViewMode = UITextFieldViewModeAlways;
    phoneTFD.placeholderColor = [UIColor colorWithHexString:@"3F4443" alpha:0.4];
    phoneTFD.maximumTextLength = 11;
    phoneTFD.keyboardType = UIKeyboardTypePhonePad;
    [containView addSubview:phoneTFD];
    
    [phoneTFD mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15);
        make.right.mas_offset(-15);
        make.height.offset(50);
        make.top.equalTo(phoneLab.mas_bottom).offset(10);
        make.bottom.mas_offset(-15);
    }];
    
    [[RACSignal merge:@[emailTFD.rac_textSignal,RACObserve(emailTFD, text)]]subscribeNext:^(NSString  *_Nullable text) {
        [weakSelf.para setObject:text forKey:weakSelf.keys[0]];
    }];
    
    [[RACSignal merge:@[phoneTFD.rac_textSignal,RACObserve(phoneTFD, text)]]subscribeNext:^(NSString  *_Nullable text) {
        [weakSelf.para setObject:text forKey:weakSelf.keys[1]];
    }];
}

@end
